package Io;


import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test3 {

    //文件字节流
    public static void main(String[] args) throws IOException {
             Test3.testFileInputStream();
             Test3.testFileOutputStream();
    }
    public static void testFileInputStream(){//输入流字节
        try {
            FileInputStream in =new FileInputStream("D:\\aa\\a\\tt1.txt");
            byte[] b=new byte[10];
            int len=0;
            while ((len=in.read(b))!=-1){
                System.out.print(new String(b,0,len));
            }
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void testFileOutputStream() {//输出流字节
        try {
            FileOutputStream out =new FileOutputStream("D:\\aa\\a\\tt2.txt");
            String str ="aaaaaa";
            out.write(str.getBytes());//把数据写到内存
            out.flush();//把内存中的数据写到硬盘
            out.close();//关闭流
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

